#include <tchar.h>
#include "../../Sources/Header/Game.h"
#include "../../Utilities/Header/Device.h"


void Update(float deltaTime)
{
	Game::GetInstance()->Update(deltaTime);
}

void Draw()
{
	Game::GetInstance()->Draw();
}

void Key(unsigned char key, bool status)
{
	Game::GetInstance()->Key(key, status);
}

void Selected()
{
	Game::GetInstance()->Selected();
}

int _tmain()
{
	LOGI("Start program\n");
	//identifying memory leaks
#if CURRENT_PLATFORM == PLATFORM_WIN32
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

	DeviceWin32* device = new DeviceWin32(400, 400, "GL2 Graphics", 0);
	IDevice::SetInstance(device);

	if (!device->w32CreateWindows())
		return 0;
	device->RegisterKeyFunc(Key);
#else
	DeviceAndroid* device = new DeviceAndroid(0, 0, 800, 600);
	IDevice::SetInstance(device);
#endif

	IDevice::GetInstance()->RegisterUpdateFunc(Update);
	IDevice::GetInstance()->RegisterDrawFunc(Draw);
	IDevice::GetInstance()->RegisterSelectedFunc(Selected);

	Game::GetInstance()->Init();
	IDevice::GetInstance()->Run();

	IDevice::DestroyInstance();
	Game::GetInstance()->Destroy();
	Game::DestroyInstance();

	_getch();
}